<!DOCTYPE html>
<!-- saved from url=(0030)http://androidannotations.org/ -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <title>AndroidAnnotations</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Pierre-Yves Ricau">

    <link href="./AndroidAnnotations_files/bootstrap.min.css" rel="stylesheet">
    <link href="./AndroidAnnotations_files/prettify.css" rel="stylesheet">
    <link href="./AndroidAnnotations_files/custom.css" rel="stylesheet">

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <link rel="shortcut icon" href="http://androidannotations.org/favicon.ico">
<script type="text/javascript" async="" src="./AndroidAnnotations_files/ga.js"></script><script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-10826408-10']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
  </head>

  <body>
  
      <a href="https://github.com/excilys/androidannotations"><img style="position: absolute; top: 0; right: 0; border: 0; z-index: 1000000;" src="./AndroidAnnotations_files/forkme_right_green_007200.png" alt="Fork me on GitHub"></a>

    <div id="menu" class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="brand" href="http://androidannotations.org/#">AndroidAnnotations</a>
          <ul class="nav">              
            <li><a href="https://github.com/excilys/androidannotations/wiki">Documentation</a></li>
            <li><a href="http://twitter.com/AndAnnotations">Twitter</a></li>
            <li><a href="http://plus.google.com/106206799999983258245">Google +</a></li>	
          </ul>
        </div>
      </div>
    </div>  

    <div class="container">
    
      <div class="content">
      
      <div class="hero-unit">
          <h1>Code Diet</h1>
          <p><strong>AndroidAnnotations</strong> is an Open Source framework that <strong>speeds up</strong> Android development. It takes care of the <strong>plumbing</strong>, and lets you concentrate on what's really important. By <strong>simplifying</strong> your code, it facilitates its <strong>maintenance</strong>.</p>
          <p><a href="https://github.com/excilys/androidannotations"><img src="./AndroidAnnotations_files/logo.png" alt="AndroidAnnotations"></a> <a href="http://www.ebusinessinformation.fr/"><img src="./AndroidAnnotations_files/supportedbylogo.png" alt="Supported by eBusiness Information"></a></p>
          <p><a class="btn btn-primary btn-large" href="https://github.com/excilys/androidannotations/wiki">Documentation »</a></p>
      </div>
      
      <div class="headline">
      	<h1>Fast Android Development. Easy maintainance.</h1>
      	<p class="headline-byline">Here is a simple example of how your code can dramatically shrink, and become much easier to understand</p>
      </div>
      
      <div class="row">
        <div class="span6">
          <h1>Before</h1>
		<hr>
<pre class="prettyprint linenums"><ol class="linenums"><li class="L0"><span class="kwd">public</span><span class="pln"> </span><span class="kwd">class</span><span class="pln"> </span><span class="typ">BookmarksToClipboardActivity</span><span class="pln"> </span><span class="kwd">extends</span><span class="pln"> </span><span class="typ">Activity</span><span class="pln"> </span><span class="pun">{</span></li><li class="L1"><span class="pln">  </span></li><li class="L2"><span class="pln">  </span><span class="typ">BookmarkAdapter</span><span class="pln"> adapter</span><span class="pun">;</span></li><li class="L3"><span class="pln">&nbsp;</span></li><li class="L4"><span class="pln">  </span><span class="typ">ListView</span><span class="pln"> bookmarkList</span><span class="pun">;</span></li><li class="L5"><span class="pln">&nbsp;</span></li><li class="L6"><span class="pln">  </span><span class="typ">EditText</span><span class="pln"> search</span><span class="pun">;</span></li><li class="L7"><span class="pln">&nbsp;</span></li><li class="L8"><span class="pln">  </span><span class="typ">BookmarkApplication</span><span class="pln"> application</span><span class="pun">;</span></li><li class="L9"><span class="pln">&nbsp;</span></li><li class="L0"><span class="pln">  </span><span class="typ">Animation</span><span class="pln"> fadeIn</span><span class="pun">;</span></li><li class="L1"><span class="pln">&nbsp;</span></li><li class="L2"><span class="pln">  </span><span class="typ">ClipboardManager</span><span class="pln"> clipboardManager</span><span class="pun">;</span></li><li class="L3"><span class="pln">&nbsp;</span></li><li class="L4"><span class="pln">  </span><span class="lit">@Override</span></li><li class="L5"><span class="pln">  </span><span class="kwd">protected</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> onCreate</span><span class="pun">(</span><span class="typ">Bundle</span><span class="pln"> savedInstanceState</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln">    </span><span class="kwd">super</span><span class="pun">.</span><span class="pln">onCreate</span><span class="pun">(</span><span class="pln">savedInstanceState</span><span class="pun">);</span></li><li class="L7"><span class="pln">&nbsp;</span></li><li class="L8"><span class="pln">    requestWindowFeature</span><span class="pun">(</span><span class="typ">Window</span><span class="pun">.</span><span class="pln">FEATURE_NO_TITLE</span><span class="pun">);</span></li><li class="L9"><span class="pln">    getWindow</span><span class="pun">().</span><span class="pln">setFlags</span><span class="pun">(</span><span class="pln">FLAG_FULLSCREEN</span><span class="pun">,</span><span class="pln"> FLAG_FULLSCREEN</span><span class="pun">);</span></li><li class="L0"><span class="pln">&nbsp;</span></li><li class="L1"><span class="pln">    setContentView</span><span class="pun">(</span><span class="pln">R</span><span class="pun">.</span><span class="pln">layout</span><span class="pun">.</span><span class="pln">bookmarks</span><span class="pun">);</span></li><li class="L2"><span class="pln">&nbsp;</span></li><li class="L3"><span class="pln">    bookmarkList </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="typ">ListView</span><span class="pun">)</span><span class="pln"> findViewById</span><span class="pun">(</span><span class="pln">R</span><span class="pun">.</span><span class="pln">id</span><span class="pun">.</span><span class="pln">bookmarkList</span><span class="pun">);</span></li><li class="L4"><span class="pln">    search </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="typ">EditText</span><span class="pun">)</span><span class="pln"> findViewById</span><span class="pun">(</span><span class="pln">R</span><span class="pun">.</span><span class="pln">id</span><span class="pun">.</span><span class="pln">search</span><span class="pun">);</span></li><li class="L5"><span class="pln">    application </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="typ">BookmarkApplication</span><span class="pun">)</span><span class="pln"> getApplication</span><span class="pun">();</span></li><li class="L6"><span class="pln">    fadeIn </span><span class="pun">=</span><span class="pln"> </span><span class="typ">AnimationUtils</span><span class="pun">.</span><span class="pln">loadAnimation</span><span class="pun">(</span><span class="kwd">this</span><span class="pun">,</span><span class="pln"> anim</span><span class="pun">.</span><span class="pln">fade_in</span><span class="pun">);</span></li><li class="L7"><span class="pln">    clipboardManager </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="typ">ClipboardManager</span><span class="pun">)</span><span class="pln"> getSystemService</span><span class="pun">(</span><span class="pln">CLIPBOARD_SERVICE</span><span class="pun">);</span></li><li class="L8"><span class="pln">&nbsp;</span></li><li class="L9"><span class="pln">    </span><span class="typ">View</span><span class="pln"> updateBookmarksButton1 </span><span class="pun">=</span><span class="pln"> findViewById</span><span class="pun">(</span><span class="pln">R</span><span class="pun">.</span><span class="pln">id</span><span class="pun">.</span><span class="pln">updateBookmarksButton1</span><span class="pun">);</span></li><li class="L0"><span class="pln">    updateBookmarksButton1</span><span class="pun">.</span><span class="pln">setOnClickListener</span><span class="pun">(</span><span class="kwd">new</span><span class="pln"> </span><span class="typ">OnClickListener</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span></li><li class="L1"><span class="pln">&nbsp;</span></li><li class="L2"><span class="pln">      </span><span class="lit">@Override</span></li><li class="L3"><span class="pln">      </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> onClick</span><span class="pun">(</span><span class="typ">View</span><span class="pln"> v</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L4"><span class="pln">        updateBookmarksClicked</span><span class="pun">();</span></li><li class="L5"><span class="pln">      </span><span class="pun">}</span></li><li class="L6"><span class="pln">    </span><span class="pun">});</span></li><li class="L7"><span class="pln">&nbsp;</span></li><li class="L8"><span class="pln">    </span><span class="typ">View</span><span class="pln"> updateBookmarksButton2 </span><span class="pun">=</span><span class="pln"> findViewById</span><span class="pun">(</span><span class="pln">R</span><span class="pun">.</span><span class="pln">id</span><span class="pun">.</span><span class="pln">updateBookmarksButton2</span><span class="pun">);</span></li><li class="L9"><span class="pln">    updateBookmarksButton2</span><span class="pun">.</span><span class="pln">setOnClickListener</span><span class="pun">(</span><span class="kwd">new</span><span class="pln"> </span><span class="typ">OnClickListener</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln">&nbsp;</span></li><li class="L1"><span class="pln">      </span><span class="lit">@Override</span></li><li class="L2"><span class="pln">      </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> onClick</span><span class="pun">(</span><span class="typ">View</span><span class="pln"> v</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L3"><span class="pln">        updateBookmarksClicked</span><span class="pun">();</span></li><li class="L4"><span class="pln">      </span><span class="pun">}</span></li><li class="L5"><span class="pln">    </span><span class="pun">});</span></li><li class="L6"><span class="pln">&nbsp;</span></li><li class="L7"><span class="pln">    bookmarkList</span><span class="pun">.</span><span class="pln">setOnItemClickListener</span><span class="pun">(</span><span class="kwd">new</span><span class="pln"> </span><span class="typ">OnItemClickListener</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span></li><li class="L8"><span class="pln">&nbsp;</span></li><li class="L9"><span class="pln">      </span><span class="lit">@Override</span></li><li class="L0"><span class="pln">      </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> onItemClick</span><span class="pun">(</span><span class="typ">AdapterView</span><span class="pun">&lt;?&gt;</span><span class="pln"> p</span><span class="pun">,</span><span class="pln"> </span><span class="typ">View</span><span class="pln"> v</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> pos</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">long</span><span class="pln"> id</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L1"><span class="pln">        </span><span class="typ">Bookmark</span><span class="pln"> selectedBookmark </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="typ">Bookmark</span><span class="pun">)</span><span class="pln"> p</span><span class="pun">.</span><span class="pln">getAdapter</span><span class="pun">().</span><span class="pln">getItem</span><span class="pun">(</span><span class="pln">pos</span><span class="pun">);</span></li><li class="L2"><span class="pln">        bookmarkListItemClicked</span><span class="pun">(</span><span class="pln">selectedBookmark</span><span class="pun">);</span></li><li class="L3"><span class="pln">      </span><span class="pun">}</span></li><li class="L4"><span class="pln">    </span><span class="pun">});</span></li><li class="L5"><span class="pln">&nbsp;</span></li><li class="L6"><span class="pln">    initBookmarkList</span><span class="pun">();</span></li><li class="L7"><span class="pln">  </span><span class="pun">}</span></li><li class="L8"><span class="pln">&nbsp;</span></li><li class="L9"><span class="pln">  </span><span class="kwd">void</span><span class="pln"> initBookmarkList</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln">    adapter </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">BookmarkAdapter</span><span class="pun">(</span><span class="kwd">this</span><span class="pun">);</span></li><li class="L1"><span class="pln">    bookmarkList</span><span class="pun">.</span><span class="pln">setAdapter</span><span class="pun">(</span><span class="pln">adapter</span><span class="pun">);</span></li><li class="L2"><span class="pln">  </span><span class="pun">}</span></li><li class="L3"><span class="pln">&nbsp;</span></li><li class="L4"><span class="pln">  </span><span class="kwd">void</span><span class="pln"> updateBookmarksClicked</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span></li><li class="L5"><span class="pln">    </span><span class="typ">UpdateBookmarksTask</span><span class="pln"> task </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">UpdateBookmarksTask</span><span class="pun">();</span></li><li class="L6"><span class="pln">&nbsp;</span></li><li class="L7"><span class="pln">    task</span><span class="pun">.</span><span class="pln">execute</span><span class="pun">(</span><span class="pln">search</span><span class="pun">.</span><span class="pln">getText</span><span class="pun">().</span><span class="pln">toString</span><span class="pun">(),</span><span class="pln"> application</span><span class="pun">.</span><span class="pln">getUserId</span><span class="pun">());</span></li><li class="L8"><span class="pln">  </span><span class="pun">}</span></li><li class="L9"><span class="pln">  </span></li><li class="L0"><span class="pln">  </span><span class="kwd">private</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">final</span><span class="pln"> </span><span class="typ">String</span><span class="pln"> BOOKMARK_URL </span><span class="pun">=</span><span class="pln"> </span><span class="com">//</span></li><li class="L1"><span class="pln">  </span><span class="str">"http://www.bookmarks.com/bookmarks/{userId}?search={search}"</span><span class="pun">;</span></li><li class="L2"><span class="pln">  </span></li><li class="L3"><span class="pln">  </span></li><li class="L4"><span class="pln">  </span><span class="kwd">class</span><span class="pln"> </span><span class="typ">UpdateBookmarksTask</span><span class="pln"> </span><span class="kwd">extends</span><span class="pln"> </span><span class="typ">AsyncTask</span><span class="pun">&lt;</span><span class="typ">String</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Void</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Bookmarks</span><span class="pun">&gt;</span><span class="pln"> </span><span class="pun">{</span></li><li class="L5"><span class="pln">&nbsp;</span></li><li class="L6"><span class="pln">    </span><span class="lit">@Override</span></li><li class="L7"><span class="pln">    </span><span class="kwd">protected</span><span class="pln"> </span><span class="typ">Bookmarks</span><span class="pln"> doInBackground</span><span class="pun">(</span><span class="typ">String</span><span class="pun">...</span><span class="pln"> </span><span class="kwd">params</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L8"><span class="pln">      </span><span class="typ">String</span><span class="pln"> searchString </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">params</span><span class="pun">[</span><span class="lit">0</span><span class="pun">];</span></li><li class="L9"><span class="pln">      </span><span class="typ">String</span><span class="pln"> userId </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">params</span><span class="pun">[</span><span class="lit">1</span><span class="pun">];</span></li><li class="L0"><span class="pln">&nbsp;</span></li><li class="L1"><span class="pln">      </span><span class="typ">RestTemplate</span><span class="pln"> client </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">RestTemplate</span><span class="pun">();</span></li><li class="L2"><span class="pln">      </span><span class="typ">HashMap</span><span class="pun">&lt;</span><span class="typ">String</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Object</span><span class="pun">&gt;</span><span class="pln"> args </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">HashMap</span><span class="pun">&lt;</span><span class="typ">String</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Object</span><span class="pun">&gt;();</span></li><li class="L3"><span class="pln">      args</span><span class="pun">.</span><span class="pln">put</span><span class="pun">(</span><span class="str">"search"</span><span class="pun">,</span><span class="pln"> searchString</span><span class="pun">);</span></li><li class="L4"><span class="pln">      args</span><span class="pun">.</span><span class="pln">put</span><span class="pun">(</span><span class="str">"userId"</span><span class="pun">,</span><span class="pln"> userId</span><span class="pun">);</span></li><li class="L5"><span class="pln">      </span><span class="typ">HttpHeaders</span><span class="pln"> httpHeaders </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">HttpHeaders</span><span class="pun">();</span></li><li class="L6"><span class="pln">      </span><span class="typ">HttpEntity</span><span class="pun">&lt;</span><span class="typ">Bookmarks</span><span class="pun">&gt;</span><span class="pln"> request </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">HttpEntity</span><span class="pun">&lt;</span><span class="typ">Bookmarks</span><span class="pun">&gt;(</span><span class="pln">httpHeaders</span><span class="pun">);</span></li><li class="L7"><span class="pln">      </span><span class="typ">ResponseEntity</span><span class="pun">&lt;</span><span class="typ">Bookmarks</span><span class="pun">&gt;</span><span class="pln"> response </span><span class="pun">=</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">exchange</span><span class="pun">(</span><span class="pln"> </span><span class="com">//</span></li><li class="L8"><span class="pln">          BOOKMARK_URL</span><span class="pun">,</span><span class="pln"> </span><span class="typ">HttpMethod</span><span class="pun">.</span><span class="pln">GET</span><span class="pun">,</span><span class="pln"> request</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Bookmarks</span><span class="pun">.</span><span class="kwd">class</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">);</span></li><li class="L9"><span class="pln">      </span><span class="typ">Bookmarks</span><span class="pln"> bookmarks </span><span class="pun">=</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">getBody</span><span class="pun">();</span></li><li class="L0"><span class="pln">&nbsp;</span></li><li class="L1"><span class="pln">      </span><span class="kwd">return</span><span class="pln"> bookmarks</span><span class="pun">;</span></li><li class="L2"><span class="pln">    </span><span class="pun">}</span></li><li class="L3"><span class="pln">&nbsp;</span></li><li class="L4"><span class="pln">    </span><span class="lit">@Override</span></li><li class="L5"><span class="pln">    </span><span class="kwd">protected</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> onPostExecute</span><span class="pun">(</span><span class="typ">Bookmarks</span><span class="pln"> result</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L6"><span class="pln">      adapter</span><span class="pun">.</span><span class="pln">updateBookmarks</span><span class="pun">(</span><span class="pln">result</span><span class="pun">);</span></li><li class="L7"><span class="pln">      bookmarkList</span><span class="pun">.</span><span class="pln">startAnimation</span><span class="pun">(</span><span class="pln">fadeIn</span><span class="pun">);</span></li><li class="L8"><span class="pln">    </span><span class="pun">}</span></li><li class="L9"><span class="pln">    </span></li><li class="L0"><span class="pln">  </span><span class="pun">}</span></li><li class="L1"><span class="pln">&nbsp;</span></li><li class="L2"><span class="pln">  </span><span class="kwd">void</span><span class="pln"> bookmarkListItemClicked</span><span class="pun">(</span><span class="typ">Bookmark</span><span class="pln"> selectedBookmark</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L3"><span class="pln">    clipboardManager</span><span class="pun">.</span><span class="pln">setText</span><span class="pun">(</span><span class="pln">selectedBookmark</span><span class="pun">.</span><span class="pln">getUrl</span><span class="pun">());</span></li><li class="L4"><span class="pln">  </span><span class="pun">}</span></li><li class="L5"><span class="pln">&nbsp;</span></li><li class="L6"><span class="pun">}</span></li></ol></pre>
        </div>
        <div class="span6">
    <h1>After</h1>
		<hr>
<pre class="prettyprint linenums"><ol class="linenums"><li class="L0"><span class="lit">@NoTitle</span></li><li class="L1"><span class="lit">@Fullscreen</span></li><li class="L2"><span class="lit">@EActivity</span><span class="pun">(</span><span class="pln">R</span><span class="pun">.</span><span class="pln">layout</span><span class="pun">.</span><span class="pln">bookmarks</span><span class="pun">)</span></li><li class="L3"><span class="kwd">public</span><span class="pln"> </span><span class="kwd">class</span><span class="pln"> </span><span class="typ">BookmarksToClipboardActivity</span><span class="pln"> </span><span class="kwd">extends</span><span class="pln"> </span><span class="typ">Activity</span><span class="pln"> </span><span class="pun">{</span></li><li class="L4"><span class="pln">  </span></li><li class="L5"><span class="pln">  </span><span class="typ">BookmarkAdapter</span><span class="pln"> adapter</span><span class="pun">;</span></li><li class="L6"><span class="pln">  </span></li><li class="L7"><span class="pln">  </span><span class="lit">@ViewById</span></li><li class="L8"><span class="pln">  </span><span class="typ">ListView</span><span class="pln"> bookmarkList</span><span class="pun">;</span></li><li class="L9"><span class="pln">&nbsp;</span></li><li class="L0"><span class="pln">  </span><span class="lit">@ViewById</span></li><li class="L1"><span class="pln">  </span><span class="typ">EditText</span><span class="pln"> search</span><span class="pun">;</span></li><li class="L2"><span class="pln">  </span></li><li class="L3"><span class="pln">  </span><span class="lit">@App</span></li><li class="L4"><span class="pln">  </span><span class="typ">BookmarkApplication</span><span class="pln"> application</span><span class="pun">;</span></li><li class="L5"><span class="pln">  </span></li><li class="L6"><span class="pln">  </span><span class="lit">@RestService</span></li><li class="L7"><span class="pln">  </span><span class="typ">BookmarkClient</span><span class="pln"> restClient</span><span class="pun">;</span></li><li class="L8"><span class="pln">&nbsp;</span></li><li class="L9"><span class="pln">  </span><span class="lit">@AnimationRes</span></li><li class="L0"><span class="pln">  </span><span class="typ">Animation</span><span class="pln"> fadeIn</span><span class="pun">;</span></li><li class="L1"><span class="pln">  </span></li><li class="L2"><span class="pln">  </span><span class="lit">@SystemService</span></li><li class="L3"><span class="pln">  </span><span class="typ">ClipboardManager</span><span class="pln"> clipboardManager</span><span class="pun">;</span></li><li class="L4"><span class="pln">&nbsp;</span></li><li class="L5"><span class="pln">  </span><span class="lit">@AfterViews</span></li><li class="L6"><span class="pln">  </span><span class="kwd">void</span><span class="pln"> initBookmarkList</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span></li><li class="L7"><span class="pln">    adapter </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">BookmarkAdapter</span><span class="pun">(</span><span class="kwd">this</span><span class="pun">);</span></li><li class="L8"><span class="pln">    bookmarkList</span><span class="pun">.</span><span class="pln">setAdapter</span><span class="pun">(</span><span class="pln">adapter</span><span class="pun">);</span></li><li class="L9"><span class="pln">  </span><span class="pun">}</span></li><li class="L0"><span class="pln">  </span></li><li class="L1"><span class="pln">  </span><span class="lit">@Click</span><span class="pun">({</span><span class="pln">R</span><span class="pun">.</span><span class="pln">id</span><span class="pun">.</span><span class="pln">updateBookmarksButton1</span><span class="pun">,</span><span class="pln"> R</span><span class="pun">.</span><span class="pln">id</span><span class="pun">.</span><span class="pln">updateBookmarksButton2</span><span class="pun">})</span></li><li class="L2"><span class="pln">  </span><span class="kwd">void</span><span class="pln"> updateBookmarksClicked</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span></li><li class="L3"><span class="pln">    searchAsync</span><span class="pun">(</span><span class="pln">search</span><span class="pun">.</span><span class="pln">getText</span><span class="pun">().</span><span class="pln">toString</span><span class="pun">(),</span><span class="pln"> application</span><span class="pun">.</span><span class="pln">getUserId</span><span class="pun">());</span></li><li class="L4"><span class="pln">  </span><span class="pun">}</span></li><li class="L5"><span class="pln">  </span></li><li class="L6"><span class="pln">  </span><span class="lit">@Background</span></li><li class="L7"><span class="pln">  </span><span class="kwd">void</span><span class="pln"> searchAsync</span><span class="pun">(</span><span class="typ">String</span><span class="pln"> searchString</span><span class="pun">,</span><span class="pln"> </span><span class="typ">String</span><span class="pln"> userId</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L8"><span class="pln">    </span><span class="typ">Bookmarks</span><span class="pln"> bookmarks </span><span class="pun">=</span><span class="pln"> restClient</span><span class="pun">.</span><span class="pln">getBookmarks</span><span class="pun">(</span><span class="pln">searchString</span><span class="pun">,</span><span class="pln"> userId</span><span class="pun">);</span></li><li class="L9"><span class="pln">    updateBookmarks</span><span class="pun">(</span><span class="pln">bookmarks</span><span class="pun">);</span></li><li class="L0"><span class="pln">  </span><span class="pun">}</span></li><li class="L1"><span class="pln">&nbsp;</span></li><li class="L2"><span class="pln">  </span><span class="lit">@UiThread</span></li><li class="L3"><span class="pln">  </span><span class="kwd">void</span><span class="pln"> updateBookmarks</span><span class="pun">(</span><span class="typ">Bookmarks</span><span class="pln"> bookmarks</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L4"><span class="pln">    adapter</span><span class="pun">.</span><span class="pln">updateBookmarks</span><span class="pun">(</span><span class="pln">bookmarks</span><span class="pun">);</span></li><li class="L5"><span class="pln">    bookmarkList</span><span class="pun">.</span><span class="pln">startAnimation</span><span class="pun">(</span><span class="pln">fadeIn</span><span class="pun">);</span></li><li class="L6"><span class="pln">  </span><span class="pun">}</span></li><li class="L7"><span class="pln">  </span></li><li class="L8"><span class="pln">  </span><span class="lit">@ItemClick</span></li><li class="L9"><span class="pln">  </span><span class="kwd">void</span><span class="pln"> bookmarkListItemClicked</span><span class="pun">(</span><span class="typ">Bookmark</span><span class="pln"> selectedBookmark</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></li><li class="L0"><span class="pln">    clipboardManager</span><span class="pun">.</span><span class="pln">setText</span><span class="pun">(</span><span class="pln">selectedBookmark</span><span class="pun">.</span><span class="pln">getUrl</span><span class="pun">());</span></li><li class="L1"><span class="pln">  </span><span class="pun">}</span></li><li class="L2"><span class="pln">&nbsp;</span></li><li class="L3"><span class="pun">}</span></li></ol></pre>
<pre class="prettyprint linenums"><ol class="linenums"><li class="L0"><span class="lit">@Rest</span><span class="pun">(</span><span class="str">"http://www.bookmarks.com"</span><span class="pun">)</span></li><li class="L1"><span class="kwd">public</span><span class="pln"> </span><span class="kwd">interface</span><span class="pln"> </span><span class="typ">BookmarkClient</span><span class="pln"> </span><span class="pun">{</span></li><li class="L2"><span class="pln">  </span></li><li class="L3"><span class="pln">  </span><span class="lit">@Get</span><span class="pun">(</span><span class="str">"/bookmarks/{userId}?search={search}"</span><span class="pun">)</span></li><li class="L4"><span class="pln">  </span><span class="typ">Bookmarks</span><span class="pln"> getBookmarks</span><span class="pun">(</span><span class="typ">String</span><span class="pln"> search</span><span class="pun">,</span><span class="pln"> </span><span class="typ">String</span><span class="pln"> userId</span><span class="pun">);</span></li><li class="L5"><span class="pln">&nbsp;</span></li><li class="L6"><span class="pun">}</span></li></ol></pre>
       </div>
      </div>      
      
      </div> <!-- /content -->
    </div> <!-- /container -->
    
    <footer>
      <p><span class="quote">"The ratio of time spent reading [code] versus writing is well over 10 to 1 [...] [therefore] making it easy to read makes it easier to write."</span> - <span class="author">Robert C. Martin</span></p>
    </footer>

    <!-- Placed at the end of the document so the pages load faster -->
    <script src="./AndroidAnnotations_files/jquery.js"></script>
    <script src="./AndroidAnnotations_files/prettify.js"></script>    
    <script src="./AndroidAnnotations_files/bootstrap.min.js"></script>
    
    <script type="text/javascript">
         prettyPrint()
    </script>    
    
  









</body></html>